package com.sduept.nwld.dataserver.controller.riskalarm;

import com.sduept.bigdata.document.entity.core.RecordAttachment;
import com.sduept.bigdata.document.services.RecordAttachmentManager;
import com.sduept.bigdata.web.jsf.controller.AbstractController;
import com.sduept.message.entity.AlarmMessageCheck;
import com.sduept.message.manager.AlarmMessageCheckManager;
import com.sduept.nwld.dataserver.manager.protection.EquipmentTripDetailManager;
import com.sduept.nwld.dataserver.model.daily.Tripping;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.PostConstruct;
import javax.inject.Named;
import javax.faces.view.ViewScoped;
import java.util.ArrayList;
import java.util.List;

@Named
@ViewScoped
public class TripException extends AbstractController{
     
	@Autowired
	private EquipmentTripDetailManager etd;
	@Autowired
	private AlarmMessageCheckManager amc;
	@Autowired
	private RecordAttachmentManager ram;
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
    private List<Tripping> trippingList=null;
    private AlarmMessageCheck check=null;
    private String lineName="";
    private String station1;
    private String station2;
    private String voltage;
    private List<RecordAttachment> attachments = new ArrayList<>();
    
    @PostConstruct
	private void init() {
    	String oId=getParameter("oId");
    	String msgId=getParameter("msgId");
    	Tripping alarm=etd.getTrippingById(oId);
    	check=amc.getAlarmMessageCheckByMsgId(msgId);
    	if(alarm!=null){
    		trippingList=etd.getOneDayTrippingById(oId);
    		if(trippingList.size()>0) {
    			Tripping trip=trippingList.get(0);
    			lineName=trip.getLineName();
    			station1=trip.getStationName1();
    			station2=trip.getStationName2();
    			voltage=trip.getVoltageClass();
    		}
    	}
    	if(null==check) {
			check=new AlarmMessageCheck();
		}
    	attachments = ram.getAttachmentsByOId(check.getId());
    }
	public AlarmMessageCheck getCheck() {
		return check;
	}
	public void setCheck(AlarmMessageCheck check) {
		this.check = check;
	}
	public List<Tripping> getTrippingList() {
		return trippingList;
	}
	public void setTrippingList(List<Tripping> trippingList) {
		this.trippingList = trippingList;
	}
	public String getLineName() {
		return lineName;
	}
	public void setLineName(String lineName) {
		this.lineName = lineName;
	}
	public String getStation1() {
		return station1;
	}
	public void setStation1(String station1) {
		this.station1 = station1;
	}
	public String getStation2() {
		return station2;
	}
	public void setStation2(String station2) {
		this.station2 = station2;
	}
	public String getVoltage() {
		return voltage;
	}
	public void setVoltage(String voltage) {
		this.voltage = voltage;
	}
	public List<RecordAttachment> getAttachments() {
		return attachments;
	}
	public void setAttachments(List<RecordAttachment> attachments) {
		this.attachments = attachments;
	}
	
}
